// Copyright (C) 2019 Ecma International. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-object.preventextensions
description: >
  Object.preventExtensions throws if O.[[PreventExtensions]]() returns false.
info: |
  Object.preventExtensions ( O )
  ...
  2. Let status be ? O.[[PreventExtensions]]().
  3. If status is false, throw a TypeError exception.
---*/

function Test() {
    const p = new Proxy({}, {
      preventExtensions() {
        return false;
      },
    });

    assert.throws(TypeError, () => {
      Object.preventExtensions(p);
    });
}

// preheat
const NUMBER_OF_PREHEAT = 1;
for (let i = 0; i < NUMBER_OF_PREHEAT; i++) {
    Test();
}

ArkTools.jitCompileAsync(Test);
assert.sameValue(ArkTools.waitJitCompileFinish(Test), true, '[JIT] JIT disabled.');

// test
const NUMBER_OF_TEST = 1; // or 2
for (let i = 0; i < NUMBER_OF_TEST; i++) {
    Test();
}
